<template>
  <div class="main">
    <myForm
      ref="myForm"
      :dataForm="dataForm"
      :isLook="isLook"
      :formItem="formItem"
      @cancel="cancel"
      @handleSubmit="handleSubmit"
    />
  </div>
</template>

<script>
import myForm from './components/myForm.vue';
import { addDamInfoRecord } from '@/api/record.js';

export default {
  components: { myForm },
  props: {
    dataForm: {
      type: Object,
      default: () => {
        return {};
      }
    },
    isLook: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      formItem: [
        {
          key: 'materialSource',
          label: '料源',
          propsType: 'input'
        },
        {
          key: 'damPorosity',
          label: '孔隙率',
          propsType: 'input'
        },
        {
          key: 'damLithology',
          label: '岩性',
          propsType: 'input'
        },
        {
          key: 'damLevelConfig',
          label: '级配',
          propsType: 'input'
        },
        {
          key: 'rollTestParam',
          label: '碾压试验参数',
          propsType: 'input'
        },
        {
          key: 'testParam',
          label: '试验参数',
          propsType: 'input'
        },
        {
          key: 'simulationParam',
          label: '模拟参数',
          propsType: 'input'
        }
      ]
    };
  },
  methods: {
    handleSubmit(values) {
      values.damId = this.dataForm.id;
      values.panelType = 3;
      addDamInfoRecord(values).then(res => {
        if (res.code == 0) {
          this.$emit('cancel', true);
        }
      });
    },
    cancel() {
      this.$emit('cancel');
    },
    resetFields() {
      this.$refs.myForm.resetFields();
    }
  }
};
</script>

<style scoped lang="scss"></style>
